package com.shem.watermark.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatTextView;

/* loaded from: classes2.dex */
public class DashTextView extends AppCompatTextView {

    /* renamed from: n */
    public Paint f13873n;

    /* renamed from: o */
    public Path f13874o;

    public DashTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        Paint paint = new Paint(1);
        this.f13873n = paint;
        paint.setColor(-1);
        this.f13873n.setStrokeWidth(3.0f);
        this.f13873n.setStyle(Paint.Style.STROKE);
        this.f13873n.setPathEffect(new DashPathEffect(new float[]{5.0f, 5.0f}, 0.0f));
        this.f13874o = new Path();
        setPadding(0, 0, 0, 3);
    }

    private float getTextWidth() {
        float f = 0.0f;
        for (int i7 = 0; i7 < getLineCount(); i7++) {
            if (f < getLayout().getLineWidth(i7)) {
                f = getLayout().getLineWidth(i7);
            }
        }
        return f == 0.0f ? getWidth() : f;
    }

    @Override // android.widget.TextView, android.view.View
    public final void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        setLayerType(1, null);
        int height = getHeight();
        this.f13874o.reset();
        float f = height;
        this.f13874o.moveTo(0.0f, f);
        this.f13874o.lineTo(getTextWidth(), f);
        canvas.drawPath(this.f13874o, this.f13873n);
    }
}